const quickSort = (arr, start, end) => {
  if (start >= end) return
  let i = start,
    j = end,
    temp = arr[start]
  while (i < j) {
    while (i < j && arr[j] > temp) {
      j--
    }
    arr[i] = arr[j]
    while (i < j && arr[i] < temp) {
      i++
    }
    arr[j] = arr[i]
  }
  arr[i] = temp
  quickSort(arr, start, i - 1)
  quickSort(arr, i + 1, end)
}
let arr = [2, 5, 3, 7, 6, 4, 21, 13, 1]
quickSort(arr, 0, arr.length - 1)
console.log(arr)